package com.typhoon.spring_redis.controller.resolver;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.support.spring.FastJsonJsonView;

public class WebExceptionResolver implements HandlerExceptionResolver  {

	public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
			Exception ex) {
		 ModelAndView mv = new ModelAndView();  
         /*  ʹ��FastJson�ṩ��FastJsonJsonView��ͼ���أ�����Ҫ�����쳣   */  
         FastJsonJsonView view = new FastJsonJsonView();  
         Map<String, Object> attributes = new HashMap<String, Object>();  
         attributes.put("code", "500");  
         attributes.put("msg", ex.getMessage());  
         view.setAttributesMap(attributes);  
         mv.setView(view);   
         return mv;  
	}

}
